//
//  SYNewsDetailViewController.m
//  MicroNews
//
//  Created by siyue on 15/10/27.
//  Copyright © 2015年 siyue. All rights reserved.
//

#import "SYNewsDetailViewController.h"
#import "SYDetialComentTableViewCell.h"

#define DeviceBounds [[UIScreen mainScreen] bounds]
#define DeviceWidth CGRectGetWidth(DeviceBounds)
#define DeviceHeight CGRectGetHeight(DeviceBounds)

@interface SYNewsDetailViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (strong,nonatomic)NSArray *array;
@end

@implementation SYNewsDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"微点资讯";
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    self.array = [NSArray arrayWithObjects:@";alfjsdl;fjl;j介绍了国际上的风景快乐赶紧来看asl;dfjl;ajsdlfjl;asdjfljkl;asdjklfjkl;asdjklfjalksdfjlkasl;kjdfjlk;asdjl;fjlk;sadjflla;ks",@";alfjsdl;fjl;jasl;dfjl;ajsdlfjl;asdjfljkl;asdjklfjkl;asdjklfjalksdfjlkasl;kjdfjlk;asdjl;fjlk;sadjflla;ks",@";alfjsdl;fjl;jasl;dfjl;ajsdlfjl;asdjfljkl;asdjklfjkl;asdjklfjalksdfjlkasl;kjdfjlk;asdjl;fjlk;lla;ks",@";alfjsdl;fjl;jasl;dfjl;ajsdlfjl;asdjfljkl;asdjklfjkl;asdjklfjalksdfjlkasl;kjdfjlk;asdjl;fjlk;sadjflla;ks",@";alfjsdl;fjl;jasl;dfjl;ajsdlfjl;asdjfljkl;asdjklfjkl;asdjklfjalksdfjlkasl;kjdfjlk;asdjl;fjlk;sadjflla;ks",@";alfjsdl;格拉夫开工fjl;jasl;dfjl;ajsdlfjl;asdjfljkl;asdjklfjkl;asdjklfjalksdfjlkasl;kjdfjlk;asdjl;fjlk;sadjflla;ks",@";alfjsdl;fjl;jasl;dfjl;ajsdlfjl;asdjfljkl;asdjklfjkl;asdjklfjalksdfjlkasl;kjdfjlk;asdjl;fjlk;sadjflla;ks",@";alfjsdl;fjl;jasl;dfjlh",@";alfjsdl;fjl;jasl;dfjl无语，计算不准吗", nil];
    
    [self requestNewsDetail];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - net

- (void)requestNewsDetail
{
    NSString *newsID = [NSString stringWithFormat:@"&id=%@",self.newsId];
    NSString *url = [NSString stringWithFormat:@"%@%@%@",HomeURL,News_Detail_URL,newsID];
    
    [[NetworkInterface shareInstance] requestForGet:url complete:^(NSDictionary *result) {
        
    } error:^(NSError *error) {
        
    }];
}

#pragma mark - table

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.array.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *reuseIdentifier = @"SYDetailCommentCell";
    
    SYDetialComentTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];

    cell.contentLabel.text = self.array[indexPath.row];
    cell.contentView.frame = cell.bounds;
    cell.contentView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin |UIViewAutoresizingFlexibleTopMargin |UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;

    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    static SYDetialComentTableViewCell *sizingCell = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sizingCell = [self.tableView dequeueReusableCellWithIdentifier:@"SYDetailCommentCell"];
    });
    sizingCell.contentLabel.text = self.array[indexPath.row];
    
    return [sizingCell heightForCell:sizingCell];
}



@end
